function Circle() {
	this.posX = Math.random() * 1990;
	this.posY = Math.random() * 1990;
	this.radius = Math.random() * 340 + 5;
	
	this.velocityX = 0;//Math.random() * 0.5 - 0.25;
	this.velocityY = 0;//Math.random() * 0.5 - 0.25;
	this.collision=false;
	this.collisionOrbit=false;
	this.color = "green";
	
	this.density = 0.000001;
	this.mass =  this.density * 4/3*Math.PI*Math.pow(this.radius, 3);
	
	//checks for collision with other circles
	this.checkCollision = function(ball) {
		var dx = this.posX - ball.posX;
		var dy = this.posY - ball.posY;
		var radii = this.radius + ball.radius;
		this.collision=false;
		if (( dx * dx )  + ( dy * dy ) < radii * radii ) {			
			this.collision=true;
		}		
		
		var radii = this.radius*1.8 + ball.radius;
		this.collisionOrbit=false;
		if (( dx * dx )  + ( dy * dy ) < radii * radii ) {			
			this.collisionOrbit=true;
		}	
	};
	
	//makes sure circles doesn't leave game area
	this.checkBoundaries = function() {
		if (this.posY > (3000 - this.radius) && this.velocityY > 0) {
			this.velocityY *= -1;
		}else if (this.posY < this.radius && this.velocityY < 0) {
			this.velocityY *= -1;
		};
		
		if (this.posX > (3000 - this.radius) && this.velocityX > 0) {
			this.velocityX *= -1;
		}else if (this.posX < this.radius && this.velocityX < 0) {
			this.velocityX *= -1;
		};
	};
	
	//update the circle movement
	this.update = function() {
		this.checkBoundaries();
		
		this.posX += this.velocityX;
		this.posY += this.velocityY;
		
	};
	
	//draws the circle
	this.draw = function(ctx, xView, yView){	
		ctx.fillStyle = this.color;
		ctx.beginPath();
		ctx.arc((this.posX) - xView, (this.posY) - yView, this.radius, 0, Math.PI * 2, true);
		ctx.closePath();
		ctx.fill();		
		
		ctx.strokeStyle = "gray";
		ctx.beginPath();
		ctx.arc((this.posX) - xView, (this.posY) - yView, this.radius*2.8, 0, Math.PI * 2, true);
		ctx.closePath();		
		ctx.lineWidth = 5;		
		ctx.stroke();	
		ctx.fillStyle = "yellow";
		ctx.font = 'bold '+25+'px Monospace';
		if(this.collision==true)ctx.fillText("collision!", (this.posX-this.radius/2) - xView, (this.posY-this.radius/2) - yView);
		if(this.collisionOrbit==true)ctx.fillText("collision orbit!", (this.posX-this.radius/2) - xView, (this.posY+50-this.radius/2) - yView);
		
		
		ctx.fillText(this.mass, (this.posX+50-this.radius/2) - xView, (this.posY+50-this.radius/2) - yView);
	};
}